import DList from "@/components/dlist";
import evaluationPopup from "../home/components/evaluation_popup";
export default {
  data() {
    return {
      evaluation_show: false,
      type: "individual",
      detailData: {},
      info: false,
      show_more: false,
      show_icon: false
    };
  },
  mounted() {
    this.type = this.$route.params.type;
    this.order_id = this.$route.params.order_id;
    console.log(this.type,typeof this.type,5223);
    this.getOrderDetail();

  },
  methods: {
    async getOrderDetail() {
      this.show_more = false;
      this.show_icon = false;
      let url = this.type == "individual" ? "plugin.be-within-call.frontend.order.personal-need.detail" : "plugin.be-within-call.frontend.order.enterprise-need.detail"
      let { data, result, msg } = await $http.get(url, { oid: this.order_id });
      if (result === 0) {
        this.$toast(msg);
        return;
      }
      this.detailData = data;
      this.info = true;
      this.$nextTick(() => {
        let offsetHeight = this.$refs.tec_text.offsetHeight;
        if(offsetHeight > 20) {
          this.show_more = true;
          this.show_icon = true;
        }
        // console.log("scrollWidth: ", this.show_more,offsetHeight)
      })
    },
    async evenButtonModels(citem,item) {
      if(citem.value == 'pay') {
        this.$router.push(
          this.fun.getUrl("orderpay", {
            status: 2,
            order_ids: this.detailData.order_id
          })
        );
      }else if(citem.value == 'cancel-pay' || citem.value == 'enterprise-cancel-pay') {
        let { data, result, msg } = await $http.post(citem.api, { oid: this.detailData.order_id });
        this.$toast(msg);
        this.getOrderDetail();
      }else if(citem.value == 'receive') {
        this.$dialog.confirm({
          title: '提示',
          message: '是否确认完成?',
        })
          .then(async () => {
            let { data, result, msg } = await $http.post(citem.api, { oid: this.detailData.order_id });
            this.$toast(msg);
            this.getOrderDetail();
          })
          .catch(() => {
            // on cancel
          });
      }else if(citem.value == 'publish') {
        this.evaluation_show = true;
      }
    },
    // 评论成功后事件处理
    commentEvent() {
      this.getOrderDetail();
    }
  },
  components: { DList , evaluationPopup }
};
